﻿@{
    ViewBag.Title = "IP地址组管理";
}
@model System.Collections.IEnumerable
<!DOCTYPE html>
<html>
<head>
 @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    <script type="text/javascript">
        if (top.boardtop) top.boardtop.head_txt.innerText = "IP地址组管理";

    </script>
   
    @Html.DevExpress().GetStyleSheets(

                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }
    )
    @Html.DevExpress().GetScripts(
                    new Script { ExtensionType = ExtensionType.ListBox }
    )

    <script type="text/javascript">
        $(function () {
            $("#toolMenu").smartFloat();
        });

        function OnBeginCallback(s, e) {
            e.customArgs["command"] = e.command;
            e.customArgs["pageIndex"] = s.pageIndex;
            e.customArgs["pageCount"] = s.pageCount;
            e.customArgs["pageRowSize"] = s.pageRowSize;
            e.customArgs["pageRowCount"] = s.pageRowCount;
        }


        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnAdd":
                    {
                        $("#popContent").attr("src", rootPath + "/Admin/IPGroupManager/IPGroupManagerEdit");
                        EditIPGroupMode.Show();
                        break;
                    }
                case "btnDelete":
                    {
                        ///批量删除
                        adManyDel();
                        break;
                    }
            }
        }

        //编码保存取消
        function cancel() {
            EditIPGroupMode.Hide();
        }

        //批量删除
        function adManyDel() {
            var groupIDs = gvEditing.GetSelectedKeysOnPage();
            if (groupIDs.length == 0) {
                alert("请选择要删除的数据");

            } else {
                if (confirm("确定删除")) {
                    var groupIDArray = "";
                    for (var i = 0; i < groupIDs.length; i++) {
                        groupIDArray += groupIDs[i] + "%!^";
                    }

                    $.ajax({
                        type: 'POST',
                        url: rootPath + "/Admin/IPGroupManager/IPGroupManagerMDelete",
                        data: { groupIDs: groupIDArray },
                        success: function (result) {
                            if (result == "ok") {
                                alert("删除成功!");
                                gvEditing.Refresh();
                            } else if (result == "error") {
                                alert("删除失败!");
                            } else {
                                alert("删除参数错误!");
                            }
                        }
                    });
                }
            }
        }
        ///修改
        function Edit(groupID) {
            $("#popContent").attr("src", rootPath + "/Admin/IPGroupManager/IPGroupManagerEdit?groupID=" + groupID);
            EditIPGroupMode.Show();
        }

        ///删除
        function Del(groupID) {
            if (confirm("确定删除")) {
                $.ajax({
                    type: 'POST',
                    url: rootPath + "/Admin/IPGroupManager/IPGroupManagerDelete",
                    data: { groupID: groupID },
                    success: function (result) {
                        if (result == "ok") {
                            alert("删除成功!");
                            gvEditing.Refresh();
                        } else if (result == "error") {
                            alert("删除失败!");
                        } else {
                            alert("删除参数错误!");
                        }
                    }
                });
            }
        }

</script>
</head>
<body>
<div class="floatToolMenu" id="toolMenu">
    @Html.DevExpress().Menu(settings =>
       {
           settings.Name = "toolBarMenu";
           settings.ItemAutoWidth = false;
           settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
           settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
           settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
           settings.Items.Add(item =>
           {
               item.Name = "btnAdd";
               item.Text = "增加";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnDelete";
               item.Text = "删除";
               item.ItemStyle.ForeColor = System.Drawing.Color.Red;
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/cancel.png");

           });
           settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
           settings.ItemLinkMode = ItemLinkMode.ContentBounds;
       }).GetHtml()
    </div>


     @Html.DevExpress().PopupControl(
    settings =>
    {
        settings.Name = "EditIPGroupMode";
        settings.Width = 700;
        settings.Height = 260;
        settings.AllowDragging = true;
        settings.CloseAction = CloseAction.CloseButton;
        settings.EnableAnimation = false;
        settings.HeaderText = "IP地址组管理";
        settings.Modal = true;
        settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
        settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
        settings.ShowFooter = true;


        settings.SetFooterTemplateContent(s =>
        {
            ViewContext.Writer.Write("<table align='center'><tr><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnOK";
                footBtnSettings.Text = "确定";
                footBtnSettings.ClientSideEvents.Click = "function(s,e){popContent.OK()}";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnCancel";
                footBtnSettings.Text = "取消";
                footBtnSettings.ClientSideEvents.Click = "cancel";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td></tr></table>");

        });
        settings.SetContent(() =>
       {
           ViewContext.Writer.Write("<iframe  id='popContent' name='popContent' style='width:100%;height:230px' frameborder='0' ></iframe>");
       });

    }).GetHtml()

    @Html.Partial("IPGroupManagerListPartial", Model)
</body>
</html>
